Skip to content

Reject boolean PyTorch normal parameters#3237

Merged
FlorianPfaff merged 2 commits into
mainfrom
bugfix/pytorch-normal-bool-params
Jun 27, 2026
Merged

Reject boolean PyTorch normal parameters#3237
FlorianPfaff merged 2 commits into
mainfrom
bugfix/pytorch-normal-bool-params

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Summary

  • add PyTorch random.normal validation for boolean loc and scale parameters before dispatching to scalar or tensor sampling paths
  • cover Python bools, NumPy bool scalars, torch bool tensors, and mixed object/list inputs in the existing PyTorch random backend regression tests

Bug fixed

The PyTorch backend accepted boolean loc/scale values for random.normal, silently treating them as numeric 0/1. Other random parameter validators already reject booleans as non-numeric control values, so this was an inconsistent and error-prone sampling path.

Validation

  • Inspected the branch diff with GitHub compare: only src/pyrecest/_backend/pytorch/random.py and tests/backend/test_pytorch_random_backend.py changed.
  • Ran py_compile locally on reconstructed edited files.
  • Exercised the patched random.normal path in a small local harness against Python bools, NumPy bool scalars, torch bool tensors, boolean tensor arrays, and mixed boolean object/list inputs.
  • Full repository pytest was not run locally because the execution environment cannot resolve github.com to clone/install the repository.

@FlorianPfaff FlorianPfaff enabled auto-merge (squash) June 27, 2026 20:59
@github-actions

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 51.49s
✅ JSON prettier 7 0 0 0 0.7s
✅ JSON v8r 7 0 0 4.13s
✅ MARKDOWN markdownlint 68 0 0 0 1.37s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.64s
✅ PYTHON black 1050 50 0 0 44.53s
✅ PYTHON isort 1050 72 0 0 3.48s
✅ REPOSITORY checkov yes no no 36.41s
✅ REPOSITORY gitleaks yes no no 6.88s
✅ REPOSITORY git_diff yes no no 0.11s
✅ REPOSITORY secretlint yes no no 22.53s
✅ REPOSITORY syft yes no no 1.81s
✅ REPOSITORY trivy-sbom yes no no 8.44s
✅ REPOSITORY trufflehog yes no no 15.83s
✅ YAML prettier 11 0 0 0 0.53s
✅ YAML v8r 11 0 0 7.88s
✅ YAML yamllint 11 0 0 0.34s

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@9.5.0 --custom-flavor-setup --custom-flavor-linters PYTHON_BLACK,PYTHON_ISORT,COPYPASTE_JSCPD,JSON_V8R,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_GITLEAKS,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

@FlorianPfaff FlorianPfaff merged commit 802856e into main Jun 27, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant